#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
using namespace std;


int main()
{
    int e = 0, sum = 2, n, a[40][40] = { 0 }, k = 0;
    cin>>n;
    a[0][0] = 1;
    for (k = 1; k <= 2 * n - 2; k++)
    {
        if (e % 2 == 0)
        {
            for (int i = 0; i < n; i++)
            {

                for (int j = 0; j < n; j++)
                {
                    if (i + j == k)
                    {
                        a[i][j] = sum;
                        sum++;
                    }
                }
            }
        }
        else
        {
            for (int i = n - 1; i >= 0; i--)
            {
                for (int j = 0; j < n; j++)
                {
                    if (i + j == k)
                    {
                        a[i][j] = sum;
                        sum++;
                    }
                }
            }
        }
        e++;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}